// todo 创建路由  配置路由规则  导出路由实例对象

// 导入路由相关页面
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Search from '@/views/Search'
import Play from '@/views/Play'

import Vue from 'vue'
//1.下载vue-router
//2.导入vue-router
import VueRouter from 'vue-router'
//3.使用vue-router
Vue.use(VueRouter)
//4.配置路由规则的数组
const routes = [
    {
        //一级页面重定向
        path: '/',
        redirect: '/layout',

    },
    {
        path: '/layout',
        component: Layout,
        redirect: '/layout/home',
        children: [

            {
                path: '/layout/home',
                component: Home,
                meta: {
                    title: '首页',
                }
            },
            {
                path: '/layout/search',
                component: Search,
                meta: {
                    title: '搜索',
                }
            },
        ]
    },
    {
        path: '/play',
        component: Play,
    },
]
//5.创建路由对象
const router = new VueRouter({
    routes,
})
//console.log(router);
//6.将路由对象挂载到Vue身上（这里不在一个文件里，需要导出）
export default router